package com.zhidisoft.admin.service.impl;

import java.math.BigInteger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhidisoft.admin.aonn.ServiceLogAnno;
import com.zhidisoft.admin.entity.Article;
import com.zhidisoft.admin.mapper.IArticleMapper;
import com.zhidisoft.admin.service.IArticleService;
import com.zhidisoft.admin.vo.PageVo;

@Service
@Transactional
public class ArticleServiceImpl implements IArticleService {
	@Autowired
	 IArticleMapper mapper;
	
	@Override
	@ServiceLogAnno("文章-添加")
	public int save(Article article) {
		return mapper.save(article.getId(),article.getTitle(), article.getInfoTitle(), article.getInfo(), article.getUserId(), article.getTypeId());
	}
	
	@Override
	@ServiceLogAnno("文章-删除")
	public int deleteById(String id) {
		return mapper.deleteById(id);
	}
	
	@Override
	@ServiceLogAnno("文章-分页查询")
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		pageVo.setList(mapper.pageList((pageNum-1)*pageSize, pageSize));
		pageVo.setTotalCount(mapper.totalCount().intValue());
		return pageVo;
	}

	@Override
	@ServiceLogAnno("文章-查询一篇文章")
	public Article findById(String id) {
		return mapper.findById(id);
	}

	@Override
	@ServiceLogAnno("文章-总篇数")
	public BigInteger totalCount() {
		return mapper.totalCount();
	}

}
